home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-05-23 | 5.0 KB | 225 lines | [TEXT/MMCC] |
- /*
- Copyright © 1991-1995 by TopSoft Inc. All rights reserved.
-
- You may distribute this file under the terms of the TopSoft
- Artistic License, accompanying this package.
-
- This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
- See the Modification History for more details.
-
- Product
- About Box
-
- FILE
- ABUString.c
-
- NAME
- ABUString.c, part of the ABox project source code,
- responsible for mix-in handling the AboutBox string stuff.
-
- DESCRIPTION
- This file contains defines for the about box modules.
-
- DEVELOPED BY
- George (ty) Tempel netromancr@aol.com
- All code in this file, and its associated header file was
- Created by George (ty) Tempel in connection with the TopSoft, Inc.
- "FilterTop" application development, except where noted.
-
- This file is based, in part, upon prior work by
- Greg Anderson <greggor@apple.com> of Apple DTS.
-
-
- CARETAKER - George (ty) Tempel <netromancr@aol.com>
- Please consult this person for any changes or suggestions to this file.
-
- MODIFICATION HISTORY
-
- dd mmm yy - xxx - patchxx: description of patch
- 10 June 94 - ty - Initial Version Created
- 20-july-94 - ty - initial version released
- 23-may-95 - ty - changes for compatibility with the CodeWarrior CW6
- release and the associated Universal Headers from Apple:
- most methods that returned references now have "Ref" at
- the end of their methods names to prevent possible collisions
- with datatypes and classes of the same name (older versions
- of the compiler didn't have a problem with this).
-
- */
-
- /*==============================================================================*/
-
- /*======= Segmentation directives ========*/
-
- //#pragma segment ty
-
- /*============ Header files ==============*/
-
- #include "ABUString.h"
- #include "ABoxDefs.h"
-
- /*=============== Globals ================*/
-
-
- /*================ CODE ==================*/
-
-
- /*=============== Globals ================*/
-
-
- /*================ CODE ==================*/
-
-
- /*=============================== ABUString::ABUString ================================*/
- ABUString::ABUString(void)
- {
- } // end ABUString
-
-
- /*=============================== ABUString::~ABUString ================================*/
- ABUString::~ABUString(void)
- {
- } // end ~ABUString
-
-
-
-
-
-
- /*=============================== ABUString::P2Ccpy ==================================*/
- //
- // Copy a pascal style string into a C string; if either parameter
- // is bad the routine does nothing.
- //
- void ABUString::P2Ccpy(char *c, Str255 p)
- {
- short index;
-
- // begin here...
-
- if (!(c && p))
- return;
- else
- index = p[0];
-
- // copy from back to front
- c[index] = '\0';
-
- while (index > 0)
- {
- c[index - 1] = p[index]; // pascal strings _start_ w/length byte
- --index;
- } // end while loop
-
- } // end P2Ccpy
-
-
-
- /*=============================== ABUString::C2Pcpy ==================================*/
- //
- // Copy a C string into a Pascal string; if either parameter
- // is bad the routine does nothing.
- //
- void ABUString::C2Pcpy(Str255 p, char *c)
- {
- short index = 0;
-
- const short kPMax = 255; // max length of an Str255
-
- // begin here...
-
- if (!(c && p))
- return;
-
- while((*c) && (index < kPMax))
- p[index++] = *c++;
- p[0] = index - 1;
- } // end of C2Pcpy
-
-
- /*=============================== ABUString::PCcmp ==================================*/
- //
- // Compare a Pascal string with a C string, returning the same values
- // that strcmp() would if we were dealing with strictly C-style strings.
- //
- short ABUString::PCcmp(Str255 p, char *c)
- {
- Str255 tempString;
- short result;
-
- // begin here...
- if (!(p && c))
- {
- if (p && !c)
- return 1;
- else if (!p && c)
- return -1;
- else
- return 0;
- }
- else
- {
- C2Pcpy(tempString, c);
- result = EqualString(p, tempString, kABcaseInsensitive, kABdiacriticalInsensitive); // in OSUtils.h
- return result;
- } // end if else block
- } // end PCcmp()
-
-
-
-
-
- /*=============================== ABUString::P2Pstrcat ==================================*/
- //
- // Copy a Pascal string onto the tail end of another (append), returning the
- // newly created string.
- //
- // Any problems with the parameters is reflected in the output string; if
- // both inputs are bad, the output is NULL; if the source is bad, the
- // output is the destination string; if the destination is bad, the output
- // is the source.
- //
- StringPtr ABUString::P2Pstrcat(Str255 dest, Str255 src)
- {
- unsigned char *destPtr;
- unsigned char *srcPtr;
- unsigned char *tPtr;
- short index;
- short max;
- const short kPMax = sizeof(Str255); // max length of an Str255
-
- // begin here...
-
- if (!(dest && src))
- if (dest && !src)
- return dest;
- else if (!dest && src)
- return src;
- else
- return NULL;
-
- srcPtr = (unsigned char*) src;
- destPtr = (unsigned char*) dest;
- max = *srcPtr;
-
- // Adjust past length & chars already in dest
-
- tPtr = destPtr + *destPtr + 1;
- ++srcPtr;
-
- // Determine how many characters we can really copy
-
- if(max + *destPtr > kPMax)
- max = kPMax - *destPtr;
- *destPtr += max;
-
- for(index = 0; index < max ; ++index)
- *tPtr++ = *srcPtr++;
-
- return dest;
-
- } // end of P2Pstrcat()
-
-
- // end of file.
-